import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
  {
    path: '/',
    name: 'Login',
    component: () => import('../views/Login.vue')
  }, 
  {
    path: '/register',
    name: 'Register',
    component: () => import('../views/Register.vue')
  }, 
  {
    path: '/upload',
    name: 'Upload',
    component: () => import('../views/Upload.vue')
  }, 
  {
    path: '/user',
    name: 'User',
    component: () => import('../views/User.vue')
  }, 
  {
    path: '/wuliu',
    name: 'Wuliu',
    component: () => import('../views/Wuliu.vue')
  },
  {
    path: '/address',
    name: 'Address',
    component: () => import('../views/Address.vue')
  }, 
  {
    path: '/pinglun',
    name: 'Pinglun',
    component: () => import('../views/Pinglun.vue')
  }, 
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router